﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace NGinnBPM.Rules.TableDriven
{
    [DataContract]
    public class RuleTable
    {
        public RuleTable()
        {
            Rows = new List<Row>();
            Columns = new List<Column>();
        }

        [DataContract]
        public class Column
        {
            [DataMember]
            public string Header { get; set; }
            [DataMember]
            public string Expression { get; set; }
        } 

        [DataContract]
        public class Row
        {
            public Row()
            {
                Values = new List<string>();
            }

            public Row(int rowNum, ICollection<string> data)
            {
                LineNumber = rowNum;
                Values = new List<string>(data);
            }

            [DataMember]
            public int LineNumber { get; set; }
            [DataMember]
            public List<string> Values { get; set; }
        }

        [DataMember]
        public List<Column> Columns { get; set; }
        
        [DataMember]
        public List<Row> Rows { get; set; }

        public string GetCell(int row, int column)
        {
            return Rows[row].Values[column];
        }
    }
}
